package com.ruoyi.xp.seller.controller;

import java.io.IOException;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xp.seller.domain.XpSellerItemInfo;
import com.ruoyi.xp.seller.service.IXpSellerItemInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 虾皮卖家商品轨迹信息Controller
 * 
 * @author chdx
 * @date 2022-11-26
 */
@Controller
@RequestMapping("/seller/SellerItemInfo")
public class XpSellerItemInfoController extends BaseController
{
    private String prefix = "seller/SellerItemInfo";

    @Autowired
    private IXpSellerItemInfoService xpSellerItemInfoService;

    @RequiresPermissions("seller:SellerItemInfo:view")
    @GetMapping()
    public String SellerItemInfo()
    {
        return prefix + "/SellerItemInfo";
    }

    /**
     * 查询虾皮卖家商品轨迹信息列表
     */
    @RequiresPermissions("seller:SellerItemInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(XpSellerItemInfo xpSellerItemInfo)
    {
        startPage();
        List<XpSellerItemInfo> list = xpSellerItemInfoService.selectXpSellerItemInfoList(xpSellerItemInfo);
        return getDataTable(list);
    }

    /**
     * 导出虾皮卖家商品轨迹信息列表
     */
    @RequiresPermissions("seller:SellerItemInfo:export")
    @Log(title = "虾皮卖家商品轨迹信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(XpSellerItemInfo xpSellerItemInfo)
    {
        List<XpSellerItemInfo> list = xpSellerItemInfoService.selectXpSellerItemInfoList(xpSellerItemInfo);
        ExcelUtil<XpSellerItemInfo> util = new ExcelUtil<XpSellerItemInfo>(XpSellerItemInfo.class);
        return util.exportExcel(list, "虾皮卖家商品轨迹信息数据");
    }

    /**
     * 新增虾皮卖家商品轨迹信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存虾皮卖家商品轨迹信息
     */
    @RequiresPermissions("seller:SellerItemInfo:add")
    @Log(title = "虾皮卖家商品轨迹信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(XpSellerItemInfo xpSellerItemInfo)
    {
        return toAjax(xpSellerItemInfoService.insertXpSellerItemInfo(xpSellerItemInfo));
    }

    /**
     * 修改虾皮卖家商品轨迹信息
     */
    @RequiresPermissions("seller:SellerItemInfo:edit")
    @GetMapping("/edit/{infoId}")
    public String edit(@PathVariable("infoId") Long infoId, ModelMap mmap)
    {
        XpSellerItemInfo xpSellerItemInfo = xpSellerItemInfoService.selectXpSellerItemInfoByInfoId(infoId);
        mmap.put("xpSellerItemInfo", xpSellerItemInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存虾皮卖家商品轨迹信息
     */
    @RequiresPermissions("seller:SellerItemInfo:edit")
    @Log(title = "虾皮卖家商品轨迹信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(XpSellerItemInfo xpSellerItemInfo)
    {
        return toAjax(xpSellerItemInfoService.updateXpSellerItemInfo(xpSellerItemInfo));
    }

    /**
     * 删除虾皮卖家商品轨迹信息
     */
    @RequiresPermissions("seller:SellerItemInfo:remove")
    @Log(title = "虾皮卖家商品轨迹信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(xpSellerItemInfoService.deleteXpSellerItemInfoByInfoIds(ids));
    }
}
